A program stack is a memory location used to temporarily store data for use by a particular microprocessor, referred to as the target processor of the stack. For example, a stack's target processor, such as microprocessor embedded in a microcontroller, can store and retrieve data from the stack for a program that it is executing. However, the memory available to implement a stack for such a target processor can be limited to a relatively small size, especially in single chip microcontrollers having many integrated features. To reduce the needed stack size, software programmers take active measures including: de-featuring functionality; avoiding deep call stacks; minimizing data sizes; re-using local variables; and the like. However, these measures often come at a cost. For example, these measures can compromise the product's robustness, violate code modularity, reduce code read-ability and often introduce error-prone constructs. Therefore, if a measure taken to optimize use of a small program stack is applied unnecessarily, e.g., the measure could be supported by the available stack size, the reduction in the stack size can result in the associated program and thus the target processor having reduced functionality. Thus, a determination of how to optimize the program can be adaptively used to reduce the effect on the functionality of the target processor.
The use of the same reference symbols in different drawings indicates similar or identical items.